unit con_LayoutCobranca;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Formulario_Padrao_Consulta, StdCtrls, TFlatButtonUnit, Buttons,
  ExtCtrls, Grids, DBGrids, DB, DBTables;

type
  TfrmCon_Layout_CobBanco = class(TFrmConsulta)
    Label1: TLabel;
    edtNome: TEdit;
    dbgBanco: TDBGrid;
    procedure FormActivate(Sender: TObject);
    procedure BtnFecharClick(Sender: TObject);
    procedure edtNomeKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
    procedure FazConsulta;
  public
    { Public declarations }
    cod_Layout: string;
  end;

var
  frmCon_Layout_CobBanco: TfrmCon_Layout_CobBanco;

implementation

uses Dm, Biblio, clsLayout_Cobranca;

var
  tds: Tdatasource;
  tq: Tquery;
  Layout: TLAYOUT_COBRANCA;

{$R *.dfm}

  { TfrmCon_Layout_CobBanco }

procedure TfrmCon_Layout_CobBanco.FazConsulta;
begin
   if edtnome.text = '' then edtnome.text := ' ';
  Layout.Consultar(tq, edtnome.text);
end;

procedure TfrmCon_Layout_CobBanco.FormActivate(Sender: TObject);
begin
  inherited;
  Layout := TLAYOUT_COBRANCA.Create;
  tds := TDataSource.create(self);
  tq := Tquery.create(self);
  tq.databasename := dmint.db.databasename;
  tds.DataSet := tq;
  dbgBanco.DataSource := tds;
  fazconsulta;
  edtnome.setfocus;
end;

procedure TfrmCon_Layout_CobBanco.BtnFecharClick(Sender: TObject);
begin
  cod_Layout := tq.fieldbyname('ID_LAYOUT').asstring;
  inherited;
end;

procedure TfrmCon_Layout_CobBanco.edtNomeKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  inherited;
  if key = 12 then FazConsulta;
end;

procedure TfrmCon_Layout_CobBanco.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  inherited;
  Layout.free;
  tds.free;
  tq.free;
end;

end.

